package dao;

import JDBC.Util.IRowMapper;
import pojo.Student;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class StudentRowMapper implements IRowMapper<List<Student>> {
    public List<Student> mapping(ResultSet rs) throws Exception {
        List<Student> list = new ArrayList<Student>();
        while(rs.next()){
            int id = rs.getInt("id");
            String name = rs.getString("name");
            int age = rs.getInt("age");
            Student stu = new Student(id,name,age);
            list.add(stu);
        }
        return list;
    }
}
